package com.guigu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.mapper.Tmapper;
import com.guigu.pojo.Stadia;
import com.guigu.pojo.Tickets;
import com.guigu.service.Tservice;
import com.guigu.vo.Pojo;
import com.guigu.vo.Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TserviceImpl extends ServiceImpl<Tmapper, Tickets> implements Tservice {
    @Autowired
    private Tmapper tmapper;
    @Override
    public Pojo<Tickets> selectTickets(Vo vo, int pageNo, int pageSize) {
       //设置分页参数
        PageHelper.startPage(pageNo, pageSize);
        //查询数据
        List<Tickets> ticketsList = tmapper.selectAll(vo);
        //封装数据
        PageInfo<Tickets> pageInfo = new PageInfo<>(ticketsList);
        //转换Pojo
        Pojo<Tickets> pojo = new Pojo<>();
        pojo.setRows(pageInfo.getList());
        pojo.setTotal(pageInfo.getTotal());
        return pojo;
    }

    @Override
    public Pojo<Stadia> selectTicketsByCondition(Vo vo, int pageNo, int pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<Stadia> stadiaList = tmapper.selectByCondition(vo);
        PageInfo<Stadia> pageInfo = new PageInfo<>(stadiaList);
        Pojo<Stadia> pojo = new Pojo<>();
        pojo.setRows(pageInfo.getList());
        pojo.setTotal(pageInfo.getTotal());
        return pojo;
    }
}
